/*
 * @(#)MyTemplate.java	2013-2-1 下午1:47:07
 * order-jsp-servlet
 * Copyright 2013 Thuisoft, Inc. All rights reserved.
 * THUNISOFT PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.thunisoft.order.common.utils;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * MyTemplate
 * 
 * @author ice
 * @version 1.0
 * 
 */
public class MyTemplate extends HibernateDaoSupport {

    /**
     * 数据源 Autowired为注解注入形式，缺点是当配置多个数据源的时候，会报错
     */
    @Autowired
    private DataSource dataSource;

    /**
     * jdbc样板对象
     */
    private JdbcTemplate jdbcTemplate = null;

    public JdbcTemplate getJdbcTemplate() {
        if (jdbcTemplate == null) {
            jdbcTemplate = new JdbcTemplate(dataSource);
        }
        return jdbcTemplate;
    }
}
